<?php 

$root = dirname(__FILE__);
require $root.'/PHPMailer/PHPMailerAutoload.php';

function sendMail($host,$fromEmail,$fromPwd,$fromName,$toEmail,$toName,$subject,$content){
	$mail = new PHPMailer;
	//$mail->SMTPDebug = 3;      // Enable verbose debug output
	$mail->isSMTP();      // Set mailer to use SMTP
	$mail->Host = $host;  // Specify main and backup SMTP servers
	$mail->SMTPAuth = true;  // Enable SMTP authentication
	$mail->CharSet = "UTF-8";
	$mail->Encoding = "base64";
	$mail->Username = $fromEmail;// SMTP username
	$mail->Password = $fromPwd;
	$mail->From = $fromEmail; //发件人邮件地址
	$mail->FromName = $fromName;
	$mail->addAddress($toEmail, $toName); //添加接受者
	$mail->isHTML(true);
	$mail->Subject = $subject;
	$mail->msgHTML($content);
	// $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
	// $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
	return $mail->send();
}
$arr = array(
	'0'=>'boyl40520@gmail.com',
	'1'=>'shilinlee.ghost@gmail.com'
	);

while ( 0 ) {
	foreach ($arr as $key => $value) {
		if(sendMail("smtp.aliyun.com","***","***","shilinlee",$value,"gmail","PHPMailerTest","内容")){
			file_put_contents('send_result.txt', '1'."\r\n",FILE_APPEND);
		}
	}
	break;
}
